package com.demo.dao;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import com.demo.domain.Cargo;


@Repository("mydao")
public class DaoCargo {
	public static Logger logger = Logger.getLogger(DaoCargo.class);
	
	@Resource
	private SqlSessionFactory ssf;
	
	public void getCargo(){
		for(int i=1; i<11; i++){
			logger.debug("进入 DaoCargo.getCargo()第 --( "+i+" )--次");
			List<Cargo> list = ssf.openSession().selectList("demo.selectCargo");
			
			for(Cargo cg : list){
				System.out.println(cg.getCargoname());
				logger.debug(cg.getCargoname());
			}
		}
	}
	
	public void insertInv() throws Exception{
		
		for (int i=1;i<=100;i++){
			ssf.openSession().insert("demo.insertInv", String.valueOf(i));
		}
		
		//throw new Exception();
	}
	
	
	public void insertLog() throws Exception{
		
		for (int i=1;i<=100;i++){
			ssf.openSession().insert("demo.insertLog", String.valueOf(i));
		}
		
		throw new Exception();
	}
	
}
